package com.qf.controller;

import com.qf.ex.MyException1;
import com.qf.ex.MyException2;
import com.qf.ex.MyException3;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/ex")
public class ExController {

    @RequestMapping("/test1")
    public String test1(Integer id) {
        System.out.println("test1调用了service");
        if (id == 1) {
            throw new MyException1("阿巴阿巴");
        }
        // 转发重定向
        return "success";
    }

    @RequestMapping("/test2")
    public void test2(String code) {
        System.out.println("test2调用了service");
        if (!code.equals("abc")) {
            throw new MyException2("嘿嘿嘿");
        }
    }

    @RequestMapping("/test3")
    public void test3() {
        System.out.println("test3调用了service");
        throw new MyException3("666");
    }

    @RequestMapping("/test4")
    public void test4() {
        System.out.println("test4调用了service");
        throw new RuntimeException("666");
    }


}
